corneroidsfandomcom-20200222-history
Luaan's experimental mod
DISCLAIMER: Unlike the officially supported modding, this can potentially be used to endanger your computer (just like with full blown mods to most games). Neither me nor the original creator of the game can take any responsility for any harm to your computer through the use of this patch. Luaan's experimental mod is a game executable patch and a library used to enhance the moddability of Corneroids. It allows you to load your own .NET library and use blocks (and eventually other game items) that are defined within. Installation steps *Make a copy of your game and copy the contents of the installation package over the game copy. *Run the patched game and create a new world using Luaan's Experimental tileset. It is possible to used any existing world, but it's always a good idea to at least make a backup of your save. You've been warned :) Usage The current version supports adding new block types to the game, including their respective inventory items. You can see this usage in Luaandrium Block, a new block that should appear in the Plating menu of the crafting table (just before the Light Aluminium Block, and it looks the same, too). Upon placing this block, it can be used (just like the crafting table) to open a simple dialog, which (at the moment) contains a button to Break the game into a debugger. Developer guide You can do full development using just the binary download, the source code is only useful if you want to see how things work. Also, I'm assuming you're proficient enough in (C#).NET programming to understand everything that has to be done. The Luaan.Corneroids.ModHack project is basically the mod loader engine, which basically handles the interop between the patched Corneroids game and your code mods. Your mod will have to reference this library. The project Luaan.Corneroids.TestMod is a sample mod project, that can be used as a reference when making a mod of your own. Prerequisites *XNA Game Studio 3.1 (free download from Microsoft) *Visual Studio 2008+ (or whatever you fancy for writing .NET code with .NET 3.5 support) Creating a new mod project Create a new Class Library project, using .NET 3.5. Reference these libraries: *CorneroidsHacked.exe *Luaan.Corneroids.ModHack.dll *Microsoft.Xna.Framework.dll *Microsoft.Xna.Framework.Game.dll *System.Data.SQLite.dll *Lidgren.Network.dll Next, add an assembly attribute (CorneroidsMod()) to Properties/AssemblyInfo.cs. This will mark your library as a mod repository. The game patch will ignore any libraries that are not marked with this attribute. And now, let's finally make a new block. Creating a new block type Corneroids blocks consist of at least two classes - one for the block in terrain and another for the inventory item variant. Let's start with the item, because that's what the mod binding looks at. Create a new class named MyBlockType, derived from BasicBlockType. Add the CorneroidsModBlockType attribute to the class - the parameter specifies the name of the xml element that will hold your block types in the itemset (the full path is itemset/blocks/''yourBlockTypeName''). Since our new block type derives from BasicBlockType, you can just go ahead and copy a block from the armors section to your section - change the name, blockId (0..255, must be unique) and itemId (0..1023, again has to be unique). And whatever else you feel like, this works pretty much the same as editing any other mod. You can then reference your block/item using these two numbers the same way as with any other blocks/items, ie. in blueprints and defaultItems. You will have to override at least two methods: *CreateBlock() - just do a simple return new MyBlock(this); Ignore the fact that MyBlock isn't defined yet, we'll get right to it :) *GetCraftingType() - this enables you to show your blueprints in the crafting table/whatever blocks, to get it to show in the Armors section, put in return typeof(BasicBlockType); Other possible types include PowerBlockType ("Power"), EngineBlockType ("Thrusters") and more. The block class is even easier. Create a new class named MyBlock, derived from BasicBlock. And yup, that's it. You can now override the exposed methods at will and experiment a bit. You should now be able to make blocks with a wide array of functionality, as long as you don't need to save any data. The simplest thing to do is make a dispenser block, which materializes items from mid-air and puts them in your inventory. For this, you have to override the CanBeUsed property to return true, and then override the UseButtonClicked method to something like this: public override void UseButtonClicked(Player player) { player.Inventory.AddItem(Engine.LoadedWorld.Itemset.GetItem(29)); } This will add a single piece of Light Aluminium Block to the inventory. You're RICH! Limitations *You can only create new custom blocks at the moment - no items. *There is currently no easy way to store any non-standard data associated with the block in the save game. *The game is actually pretty rigid, so interactions with other (original) blocks may be difficult (you can see my attempt at making a trigger transmitter block in the source - basically a simple logic element, that could be expanded into any kind of functions, including the basic AND, OR etc. logic functions; It would be easy enough to make it work, but there's a lot of things that can't be done without more patches to the game - behaviour when TriggerBlocks are destroyed (they should also be removed from the transmitter bindings) and saving and loading the trigger mappings). News *2012-11-18 - After some experimentation, I've managed to make a new trigger block - ToggleTriggerBlock. When you bind it to a console, pressing the associated key will trigger this block "forever" (until you reload the block), pressing it again will deactivate it again. When the block is triggered, it will trigger every trigger block in an adjacent console block's red keygroup. Similarly, I've added another trigger block, which simply retransmits the trigger signal it gets to an adjacent console. Sadly, it can't be used to trigger engines in an overlapping way thanks to some engine quirks. *2012-11-15 - I've just made an automatic patcher application. This should make it relatively easy to apply the various patches to newer versions of the game (as they come). Editing the IL by hand is vastly faster, though, at least for the simple stuff. On the bright side, it will allow me to modify the original game blocks and their relations much more easily, which means more modding fun! Download links You can download the patch, mod library and test mod here. Again, this is currently experimental only and has no safety features. Backup your saves, backup your game and don't use mods from people you don't trust. Also, if I get a message from the game developers that they don't approve of this work, I'm removing it immediately. I'm just trying to help. The current version uses Corneroids 1.0.5. Binaries - http://dev.luaan.cz/lcem/lcem.bin.zip Source code - http://dev.luaan.cz/lcem/lcem.src.zip Enjoy, and please comment if you're interested or if you need help getting this to work, this is only a provisional page :) Category:Item Sets